package com.novel.authorization.staff.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.novel.authorization.staff.entity.NfEmail;
import com.novel.authorization.staff.mapper.NfEmailMapper;
import com.novel.authorization.staff.service.NfEmailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 发邮件设置
 *
 * @author 樊温军
 * @date Wed May 07 10:50:56 CST 2025
 */
@Slf4j
@Service
@AllArgsConstructor
public class NfEmailServiceImpl extends ServiceImpl<NfEmailMapper, NfEmail> implements NfEmailService {

    @Override
    public List<NfEmail> getNfEmailList(NfEmail nfEmail) {
        return baseMapper.getList(nfEmail);
    }

    @Override
    public IPage<NfEmail> getPage(Page<NfEmail> page, NfEmail nfEmail) {
        return baseMapper.getPage(page, nfEmail);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long saveOneNfEmail(NfEmail nfEmail) {
        this.saveOrUpdate(nfEmail);
        return nfEmail.getId();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delById(Long id) {
        baseMapper.delete(Wrappers.<NfEmail>query().lambda().in(NfEmail::getId, id));
    }

    @Override
    public NfEmail queryById(Long id) {
        return baseMapper.selectById(id);
    }
}
